import React, { useEffect } from 'react'
import { useDispatch, useSelector } from 'react-redux'
import avatar from '../assets/back.jpg'
import { reqGetNews } from '../store/actions/new'
export default function NewsList() {
  const dispatch = useDispatch()
  const active =  useSelector(state => state.channels.active)
  useEffect(() => {
    dispatch(reqGetNews(active))
  },[dispatch,active])
  const newsList =  useSelector(state => state.news)
  return (
    <div className="list">
      {newsList.map((item,index) =>  
        {
          return (
            <div key={item.aut_id} className="article_item">
              <h3 className="van-ellipsis">{item.aut_name}</h3>
              <div className="img_box">
                <img src={item.cover.type?item.cover.images[0]:avatar} className="w100" alt="" />
              </div>
              <div className="info_box">
                <span>13552285417</span>
                <span>{item.comm_count}评论</span>
                <span>{item.pubdate}</span>
              </div>
          </div>
          )
        }
      )}
    </div>
  )
}

